package com.wrx.server.controller;


import com.wrx.server.pojo.*;
import com.wrx.server.service.IBarService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wrx
 * @since 2021-04-20
 */
@RestController
public class BarController{

    @Autowired
    private IBarService barService;


    @ApiOperation(value = "创建新吧")
    @PostMapping("/bar/create")
    public RespBean register(@RequestBody Bar bar, HttpServletRequest request) {

        return barService.registerBar(bar, request);
    }

    @ApiOperation(value = "用PageHelper分页输出贴吧")
    @PostMapping("/bar/putBarPageHelper")
    public RespBean putBarPageHelper(@RequestBody PageBean pageBean){
        return barService.putAllUserByPage(pageBean.getPageNum(),pageBean.getPageSize());
    }
    @ApiOperation(value = "根据bar_id查询一条贴吧记录")
    @PostMapping("/bar/selBarById")
    public RespBean selBarById(@RequestBody PageBean pageBean){
        return barService.selBarById(pageBean.getNum1());
    }

    @ApiOperation(value = "根据bar_id查询一条贴吧记录以及吧主昵称")
    @PostMapping("/bar/selBarInfoAndUserNetNameById")
    public RespBean selBarInfoAndUserNetNameById(@RequestBody PageBean pageBean){
        return barService.selBarInfoAndUserNetNameById(pageBean.getNum1());
    }

    @ApiOperation(value = "根据bar_id查询一条贴吧记录、吧主昵称以及是否关注")
    @PostMapping("/bar/selBarInfo-userNetName-collectState")
    public RespBean selBarInfoUserNetNameCollectStateById(@RequestBody PageBean pageBean,HttpServletRequest request){
        return barService.selBarInfoUserNetNameCollectStateById(pageBean.getNum1(),request);
    }

    @ApiOperation(value = "根据theme_post_id查询一条贴吧记录")
    @PostMapping("/bar/selBarByThemePostId")
    public RespBean selBarByThemePostId(@RequestBody CommonBean commonBean){
        return barService.selBarByThemePostId(commonBean.getId());
    }


}
